package org.skywork.top.core.algorithm.num;


import java.util.HashMap;
import java.util.Map;

/**
 * Excel 表列名称
 */
public class no_168 {


    /**
     * 给你一个整数 columnNumber ，返回它在 Excel 表中相对应的列名称。
     */
    public String convertToTitle(int columnNumber) {
        Map<Integer, String> map = new HashMap<>();
        map.put(1, "A");
        map.put(2, "B");
        map.put(3, "C");
        map.put(4, "D");
        map.put(5, "E");
        map.put(6, "F");
        map.put(7, "G");
        map.put(8, "H");
        map.put(9, "I");
        map.put(10, "J");
        map.put(11, "K");
        map.put(12, "L");
        map.put(13, "M");
        map.put(14, "N");
        map.put(15, "O");
        map.put(16, "P");
        map.put(17, "Q");
        map.put(18, "R");
        map.put(19, "S");
        map.put(20, "T");
        map.put(21, "U");
        map.put(22, "V");
        map.put(23, "W");
        map.put(24, "X");
        map.put(25, "Y");
        map.put(26, "Z");
        String str = "";
        while (columnNumber > 0){
            int num = columnNumber % 26;
            columnNumber = columnNumber / 26;
            if (num == 0){
                columnNumber--;
                num = 26;
            }
            str = map.get(num) + str;
        }
        return str;
    }

    public static void main(String[] args) {
        no_171 no = new no_171();
        int ab = no.titleToNumber("AB");
        System.out.println(ab);
    }
}
